<?php

namespace Gairal\Frank\CVBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Gairal\CoreBundle\Entity\Menu;

class CVController extends Controller {
    
    /**
     * 
     * This is useless
     */
    public function indexAction() {
        $menus = array(
            new Menu(null, 'Experience', 'CVExperience'),
            new Menu(null, 'Skills', 'CVSkills'),
            new Menu(null, 'Motivation', 'CVMotivation'),
            new Menu(null, 'Education', 'CVEducation'),
            new Menu(null, 'Interests', 'CVInterests')
        );
        return $this->render('GairalFrankCVBundle:CV:index.html.twig', array(
                    'action' => 'Homepage',
                    'menus' => $menus
        ));
    }

    public function motivationAction() {
        
        $motivation = $this->getDoctrine()
                ->getManager()
                ->getRepository('GairalCoreBundle:Motivation')
                ->findIt();
        
        return $this->render('GairalFrankCVBundle:CV:motivation.html.twig', array(
                    'action' => 'motivation',
                    'motivation' => $motivation
        ));
    }

    public function experienceAction() {
        //Get all Experience
        $listExperience = $this->getDoctrine()
                ->getManager()
                ->getRepository('GairalCoreBundle:Experience')
                ->findAllWithSkills();

        return $this->render('GairalFrankCVBundle:CV:experience.html.twig', array(
                    'action' => 'experience',
                    'listExperience' => $listExperience
        ));
    }

    public function educationAction() {
        //Get all Education
        $listEducation = $this->getDoctrine()
                ->getManager()
                ->getRepository('GairalCoreBundle:Education')
                ->findAllWithSkills();

        return $this->render('GairalFrankCVBundle:CV:education.html.twig', array(
                    'action' => 'education',
                    'listEducation' => $listEducation
        ));
    }

    public function skillsAction() {
        //Get entity manager
        $listCategory = $this->getDoctrine()
                ->getManager()
                ->getRepository('GairalCoreBundle:Category')
                ->findAllWithSkills();

        return $this->render('GairalFrankCVBundle:CV:skills.html.twig', array(
                    'action' => 'skills',
                    'listCategory' => $listCategory
        ));
    }

    public function interestsAction() {
        //Get entity manager
        $em = $this->getDoctrine()
                ->getManager();

        //Get all Interests
        $listCategory = $em->getRepository('GairalCoreBundle:Category')
                ->findAllWithInterests();

        //Get all Travels
        $listTravels = $em->getRepository('GairalCoreBundle:Travel')
                ->findAllJson();

        return $this->render('GairalFrankCVBundle:CV:interests.html.twig', array(
                    'action' => 'interests',
                    'listCategory' => $listCategory,
                    'travels' => $listTravels
        ));
    }

    public function menuAction($routeName) {
        $menus = array(
            new Menu($routeName, 'Experience', 'CVExperience'),
            new Menu($routeName, 'Skills', 'CVSkills'),
            new Menu($routeName, 'Motivation', 'CVMotivation'),
            new Menu($routeName, 'Education', 'CVEducation'),
            new Menu($routeName, 'Interests', 'CVInterests')
        );
        return $this->render('::menu.html.twig', array(
            'menus' => $menus
        ));
    }

}